package edu.neu.agv_backend.service;

import edu.neu.agv_backend.dto.*;
import edu.neu.agv_backend.remote.RemoteClient;
import org.springframework.stereotype.Service;

@Service
public class FlawService {

    private final RemoteClient client;

    public FlawService(RemoteClient client) {
        this.client = client;
    }

    public TableDataInfo<AgvFlawDto> listFlaw(String query) {
        return client.get("/agv/flaw/list" + query, TableDataInfo.class).getBody();
    }

    public AjaxResult<AgvFlawDto> getFlaw(Long id) {
        return client.get("/agv/flaw/" + id, AjaxResult.class).getBody();
    }

    public AjaxResult<Void> addFlaw(AgvFlawDto dto) {
        return client.post("/agv/flaw", dto, AjaxResult.class).getBody();
    }

    public AjaxResult<Void> updateFlaw(AgvFlawDto dto) {
        return client.put("/agv/flaw", dto, AjaxResult.class).getBody();
    }

    public AjaxResult<Void> delFlaw(Long id) {
        return client.delete("/agv/flaw/" + id, AjaxResult.class).getBody();
    }

    public AjaxResult<Void> liveInfo(Long id) {
        return client.get("/agv/flaw/live/" + id, AjaxResult.class).getBody();
    }

    public AjaxResult<Void> checkAllConfirmed(Long id) {
        return client.get("/agv/flaw/check/" + id, AjaxResult.class).getBody();
    }
} 